/* 
 * File:   FractalJulia.cpp
 * Author: amouro-m
 * 
 * Created on 15 mai 2010, 17:05
 */

#include "FractalJulia.hpp"

FractalJulia::FractalJulia(unsigned int iter_max, double cx, double cy):
Fractal(-2,2,-2,2),
_iter_max(iter_max),
_cx(cx),
_cy(cy)
{}

FractalJulia::~FractalJulia() {}

Uint32
FractalJulia::compute(const double x, const double y) const
{
    double        zx = x, zy = y, tmp;
    unsigned int  i = 0;

    for (i = 0; (zx*zx + zy*zy) <= _bail && i < _iter_max; ++i)
    {
        tmp = zx*zx - zy*zy + _cx;
        zy = 2*zx*zy + _cy;
        zx = tmp;
    }

    return i;
}

